<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  <title>tango.math.GammaFunction</title>
  <link href="./css/style.css" rel="stylesheet" type="text/css"/>
  <!-- <link href="./img/icon.png" rel="icon" type="image/png"/> -->
  <script type="text/javascript" src="./js/jquery.js"></script>
  <script type="text/javascript" src="./js/modules.js"></script>
  <script type="text/javascript" src="./js/quicksearch.js"></script>
  <script type="text/javascript" src="./js/navigation.js"></script>
  <!--<script type="text/javascript" src="./js/jquery.treeview.js"></script>-->
  <script type="text/javascript">
    var g_moduleFQN = "tango.math.GammaFunction";
  </script>
  
</head>
<body>
<div id="content">
  <h1><a href="./htmlsrc/tango.math.GammaFunction.html" class="symbol">tango.math.GammaFunction</a></h1>
  
<div class="summary">Implementation of the gamma and beta functions, and their integrals.</div>
<p class="sec_header">License:</p>BSD style: see <a href="http://www.dsource.org/projects/tango/wiki/LibraryLicense">license.txt</a>
<p class="sec_header">Authors:</p>Stephen L. Moshier (original C code). Conversion to D by Don Clugston
<dl>
<dt class="decl">real <a class="symbol _variable" name="MAXGAMMA" href="./htmlsrc/tango.math.GammaFunction.html#L35" kind="variable" beg="35" end="35">MAXGAMMA</a>; <span class="attrs">[<span class="stc">const</span>]</span> <a title="Permalink to this symbol" href="#MAXGAMMA" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.math.GammaFunction.html#L35">#</a></dt>
<dd class="ddef">
<div class="summary">The maximum value of x for which gamma(x) &lt; real.infinity.</div></dd>
<dt class="decl">real <a class="symbol _function" name="sgnGamma" href="./htmlsrc/tango.math.GammaFunction.html#L134" kind="function" beg="134" end="149">sgnGamma</a><span class="params">(real <em>x</em>)</span>; <a title="Permalink to this symbol" href="#sgnGamma" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.math.GammaFunction.html#L134">#</a></dt>
<dd class="ddef">
<div class="summary">The sign of &#915;(x).</div>
Returns -1 if &#915;(x) &lt; 0,  +1 if &#915;(x) &gt; 0,
 <span class="red">NAN</span> if sign is indeterminate.</dd>
<dt class="decl">real <a class="symbol _function" name="gamma" href="./htmlsrc/tango.math.GammaFunction.html#L182" kind="function" beg="182" end="265">gamma</a><span class="params">(real <em>x</em>)</span>; <a title="Permalink to this symbol" href="#gamma" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.math.GammaFunction.html#L182">#</a></dt>
<dd class="ddef">
<div class="summary">The Gamma function, &#915;(x)</div>
&#915;(x) is a generalisation of the factorial function
  to real and complex numbers.
  Like x!, &#915;(x+1) = x*&#915;(x).
<p class="bl"/>
  Mathematically, if z.re &gt; 0 then
   &#915;(z) = <big>&#8747;<sub><small>0</small></sub><sup>&infin;</sup></big> t<sup>z-1</sup>e<sup>-t</sup> dt
<p class="bl"/>
  <table border=1 cellpadding=4 cellspacing=0>
      <caption>Special Values</caption>
      
    <tr><th>x</th> <th>&#915;(x) </th></tr>
    <tr><td><span class="red">NAN</span></td> <td><span class="red">NAN</span>      </td></tr>
    <tr><td>&plusmn;0.0</td> <td>&plusmn;&infin;</td></tr>
    <tr><td>integer > 0</td> <td>(x-1)!      </td></tr>
    <tr><td>integer < 0</td> <td><span class="red">NAN</span>      </td></tr>
    <tr><td>+&infin;</td> <td>+&infin;    </td></tr>
    <tr><td>-&infin;</td> <td><span class="red">NAN</span>      </td></tr>
  </table></dd>
<dt class="decl">real <a class="symbol _function" name="logGamma" href="./htmlsrc/tango.math.GammaFunction.html#L317" kind="function" beg="317" end="397">logGamma</a><span class="params">(real <em>x</em>)</span>; <a title="Permalink to this symbol" href="#logGamma" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.math.GammaFunction.html#L317">#</a></dt>
<dd class="ddef">
<div class="summary">Natural logarithm of gamma function.</div>
Returns the base e (2.718...) logarithm of the absolute
 value of the gamma function of the argument.
<p class="bl"/>
 For reals, logGamma is equivalent to log(fabs(gamma(x))).
<p class="bl"/>
  <table border=1 cellpadding=4 cellspacing=0>
      <caption>Special Values</caption>
      
    <tr><th>x</th> <th>logGamma(x)   </th></tr>
    <tr><td><span class="red">NAN</span></td> <td><span class="red">NAN</span>      </td></tr>
    <tr><td>integer <= 0</td> <td>+&infin;    </td></tr>
    <tr><td>&plusmn;&infin;</td> <td>+&infin;    </td></tr>
  </table></dd>
<dt class="decl">real <a class="symbol _function" name="beta" href="./htmlsrc/tango.math.GammaFunction.html#L457" kind="function" beg="457" end="462">beta</a><span class="params">(real <em>x</em>, real <em>y</em>)</span>; <a title="Permalink to this symbol" href="#beta" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.math.GammaFunction.html#L457">#</a></dt>
<dd class="ddef">
<div class="summary">Beta function</div>
The beta function is defined as
<p class="bl"/>
 beta(x, y) = (&Gamma;(x) &Gamma;(y))/&Gamma;(x + y)</dd>
<dt class="decl">real <a class="symbol _function" name="betaIncomplete" href="./htmlsrc/tango.math.GammaFunction.html#L491" kind="function" beg="491" end="581">betaIncomplete</a><span class="params">(real <em>aa</em>, real <em>bb</em>, real <em>xx</em>)</span>; <a title="Permalink to this symbol" href="#betaIncomplete" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.math.GammaFunction.html#L491">#</a></dt>
<dd class="ddef">
<div class="summary">Incomplete beta integral</div>
Returns incomplete beta integral of the arguments, evaluated
 from zero to x. The regularized incomplete beta function is defined as
<p class="bl"/>
 betaIncomplete(a, b, x) = &Gamma;(a+b)/(&Gamma;(a) &Gamma;(b)) *
 <big>&#8747;<sub><small>0</small></sub><sup>x</sup></big> t<sup>a-1</sup>(1-t)<sup>b-1</sup> dt
<p class="bl"/>
 and is the same as the the cumulative distribution function.
<p class="bl"/>
 The domain of definition is 0 &lt;= x &lt;= 1.  In this
 implementation a and b are restricted to positive values.
 The integral from x to 1 may be obtained by the symmetry
 relation
<p class="bl"/>
    betaIncompleteCompl(a, b, x )  =  betaIncomplete( b, a, 1-x )
<p class="bl"/>
 The integral is evaluated by a continued fraction expansion
 or, when b*x is small, by a power series.</dd>
<dt class="decl">real <a class="symbol _function" name="betaIncompleteInv" href="./htmlsrc/tango.math.GammaFunction.html#L591" kind="function" beg="591" end="815">betaIncompleteInv</a><span class="params">(real <em>aa</em>, real <em>bb</em>, real <em>yy0</em>)</span>; <a title="Permalink to this symbol" href="#betaIncompleteInv" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.math.GammaFunction.html#L591">#</a></dt>
<dd class="ddef">
<div class="summary">Inverse of incomplete beta integral</div>
Given y, the function finds x such that
<p class="bl"/>
  betaIncomplete(a, b, x) == y
<p class="bl"/>
  Newton iterations or interval halving is used.</dd>
<dt class="decl">real <a class="symbol _function" name="gammaIncomplete" href="./htmlsrc/tango.math.GammaFunction.html#L1103" kind="function" beg="1103" end="1143">gammaIncomplete</a><span class="params">(real <em>a</em>, real <em>x</em>)</span>; <a title="Permalink to this symbol" href="#gammaIncomplete" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.math.GammaFunction.html#L1103">#</a></dt>
<dt class="decl">real <a class="symbol _function" name="gammaIncompleteCompl" href="./htmlsrc/tango.math.GammaFunction.html#L1146" kind="function" beg="1146" end="1212">gammaIncompleteCompl</a><span class="params">(real <em>a</em>, real <em>x</em>)</span>; <a title="Permalink to this symbol" href="#gammaIncompleteCompl" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.math.GammaFunction.html#L1146">#</a></dt>
<dd class="ddef">
<div class="summary">Incomplete gamma integral and its complement</div>
These functions are defined by
<p class="bl"/>
   gammaIncomplete = ( <big>&#8747;<sub><small>0</small></sub><sup>x</sup></big> e<sup>-t</sup> t<sup>a-1</sup> dt )/ &#915;(a)
<p class="bl"/>
  gammaIncompleteCompl(a,x)   =   1 - gammaIncomplete(a,x)
 = (<big>&#8747;<sub><small>x</small></sub><sup>&infin;</sup></big> e<sup>-t</sup> t<sup>a-1</sup> dt )/ &#915;(a)
<p class="bl"/>
 In this implementation both arguments must be positive.
 The integral is evaluated by either a power series or
 continued fraction expansion, depending on the relative
 values of a and x.</dd>
<dt class="decl">real <a class="symbol _function" name="gammaIncompleteComplInv" href="./htmlsrc/tango.math.GammaFunction.html#L1226" kind="function" beg="1226" end="1338">gammaIncompleteComplInv</a><span class="params">(real <em>a</em>, real <em>p</em>)</span>; <a title="Permalink to this symbol" href="#gammaIncompleteComplInv" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.math.GammaFunction.html#L1226">#</a></dt>
<dd class="ddef">
<div class="summary">Inverse of complemented incomplete gamma integral</div>
Given a and y, the function finds x such that
<p class="bl"/>
  gammaIncompleteCompl( a, x ) = p.
<p class="bl"/>
 Starting with the approximate value x = a t<sup>3</sup>, where
 t = 1 - d - normalDistributionInv(p) sqrt(d),
 and d = 1/9a,
 the routine performs up to 10 Newton iterations to find the
 root of incompleteGammaCompl(a,x) - p = 0.</dd>
<dt class="decl">real <a class="symbol _function" name="digamma" href="./htmlsrc/tango.math.GammaFunction.html#L1368" kind="function" beg="1368" end="1439">digamma</a><span class="params">(real <em>x</em>)</span>; <a title="Permalink to this symbol" href="#digamma" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.math.GammaFunction.html#L1368">#</a></dt>
<dd class="ddef">
<div class="summary">Digamma function</div>
The digamma function is the logarithmic derivative of the gamma function.
<p class="bl"/>
  digamma(x) = d/dx logGamma(x)</dd></dl>
</div>
<div id="footer">
  <p>Based on the CEPHES math library, which is
            Copyright (C) 1994 Stephen L. Moshier (moshier@world.std.com).</p>
  <p>Page generated by <a href="http://code.google.com/p/dil">dil</a> on Fri Dec 26 04:04:14 2008. Rendered by <a href="http://code.google.com/p/dil/wiki/Kandil">kandil</a>.</p>
</div>
</body>
</html>